<template>
  <view class="pas" :class="currentTheme">
    <a-nabbar name="找回密码" />
    <view class="content" id="password">
      <item-box :padding="0">
        <view class="u-padding-left-40 u-padding-right-40">
          <label-box
            label="手机号"
            labelWidth="130"
            labelSize="32"
            paddingTb="20"
          >
            <u-input
              v-model="form.phone"
              :clearable="false"
              border
              :borderColor="currentThemeObj.inputBorderColor"
              placeholder="请输入手机号"
							type="number"
					    maxlength="11"
              :placeholder-style="`color:${currentThemeObj.placeholderColor}`"
            ></u-input>
          </label-box>
        </view>
        <view class="u-padding-left-40 u-padding-right-40">
          <label-box
            label="验证码"
            labelWidth="130"
            labelSize="32"
            paddingTb="20"
          >
            <view class="u-inline-flex">
              <u-input
                v-model="form.smsCode"
                :clearable="false"
                border
                :borderColor="currentThemeObj.inputBorderColor"
                placeholder="请输入验证码"
                :placeholder-style="`color:${currentThemeObj.placeholderColor}`"
                maxlength="6" 
              ></u-input>
              <view class="u-margin-left-20">
                <item-btn
                  @click="getCodeVali"
                  :height="64"
                  :bgColor="currentThemeObj.primary"
                  :disabled="time > 0"
									width="152rpx"
                >
                  <text class="u-font-24">{{ timeTxt }}</text>
                </item-btn>
              </view>
            </view>
          </label-box>
        </view>
      </item-box>
    </view>
    <fixed-team btnText="确定" @btnClick="submitPay"></fixed-team>
  </view>
</template>

<script>
import time from "@/pagesA/login/validateCodeTime";
import { customRequest } from "@/api/crud.js";
export default {
  name: "payRetrieve",
  mixins: [time],
  data() {
    return {
      form: {
        phone: "",
        smsCode: "",
      },
      option: {},
    };
  },
  onLoad(option) {
    this.option = option;
  },
  methods: {
    //获取验证码
    getCodeVali() {
      if (!this.$u.test.mobile(this.form.phone)) {
        this.$u.toast("手机号码不正确");
        return false;
      }
      this.getCode({
        phone: this.form.phone,
        type: 11,
      });
    },
    //检查验证码
    submitPay() {
      if (!this.$u.test.mobile(this.form.phone)) {
        this.$u.toast("手机号码不正确");
        return false;
      }
      if (!this.form.smsCode) {
        this.$u.toast("验证码不正确");
        return false;
      }
      customRequest(this.form, "user", "shopApi", "checkForgetPsdCode").then(
        (res) => {
          //给payPassword设置个type在本地 然后返回页面再获取本地路径
          uni.setStorageSync("payPassword", { ...this.option, type: 1 });
          // this.$u.route({
          //   type: "back",
          // });
          this.$u.route({
          	url: '/pagesB/wallet/payPassword',
          	type:'redirectTo',
          	params:{
          		...this.option,
          		type:1 //重新设置密码
          	}
          })
        }
      );
    },
  },
};
</script>
<style scoped lang="scss">
.pas {
  padding: 0 32rpx;
}
.content {
  margin-top: 40rpx;
}
</style>